package day09.ExceptionTest;

import com.sun.security.jgss.GSSUtil;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        while(true){
            try {
                f();
                break;
            }catch (ArrayIndexOutOfBoundsException e){
                System.out.println("请输入两个数字，用逗号隔开");
            }catch (ArithmeticException e){
                System.out.println("0不能作为除数！");
            }catch (Exception e){
                System.out.println("输入错误, 请重新尝试");
            }
        }


    }

    private static void f() {
        /**
         * "6435, 45" --->["6435","45"]
         * --->
         * 6435
         * 45
         */
        System.out.println("输入逗号隔开的两个整数");
        String s = new Scanner(System.in).nextLine();
        String[] a = s.split(",");
        int n1 = Integer.parseInt(a[0]);
        int n2 = Integer.parseInt(a[1]);
        int r = n1 / n2;
        System.out.println(r);
    }

}
